
'use strict';  
const uniPush = uniCloud.getPushManager({appId:"__UNI__B8859F8"}) //注意这里需要传入你的应用appId  
exports.main = async (event, context) => {  
	var body = event.body;
	var data = {};
	if (!body) {
		// utils调用
		return await uniPush.sendMessage({
			"push_clientid": event.cids,
			"title": event.title,
			"content": event.content,
			"payload": event.data,
			"force_notification": true,
			"request_id": event.request_id
		});
	}
	// post接口调用
	data = JSON.parse(body);
    return await uniPush.sendMessage({
		"push_clientid": data.cids,
		"title": data.title,
		"content": data.content,
		"payload": data.data,
		"force_notification": true,
		"request_id": data.request_id
    });
};

// 推送测试
// exports.main = async (event, context) => {  
//     return await uniPush.sendMessage({  
//         "push_clientid": ["2446f32b96f6c80d7469b7ae36d74dec"],     //填写上一步在uni-app客户端获取到的客户端推送标识push_clientid  
//         // "force_notification": true,  //填写true，客户端就会对在线消息自动创建“通知栏消息”。  
//         "title": "大宝大宝",      
//         "content": "I L O V E Y O U ~",  
//         "payload": {  
//             "text":"体验一下uni-push2.0"  
//         }, 
//     })  
// };